﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer.DataObject
{
    public class RequestPerson
    {
        public string ID { get; set; }
        public string RequestID { get; set; }
        public string PersonID { get; set; }
        public string EditorUserID { get; set; }
        public string EditorUserName { get; set; }
        public string PersonName { get; set; }
        public string Status { get; set; }
        public string Timestamp { get; set; }
        public string BackColor { get; set; }

        public RequestPerson(DataAccessLayer.RequestPerson RequestPerson)
        {
            this.ID = RequestPerson.ID.ToString();
            this.RequestID = RequestPerson.RequestID.ToString();
            this.PersonID = RequestPerson.PersonID.ToString();
            this.PersonName = RequestPerson.sPerson.Persons.Last().DisplayName;
            this.EditorUserID = RequestPerson.EditorUserID.ToString();
            this.EditorUserName = RequestPerson.sUser.Users.Last().Username;
            switch ((RequestPersonStatus)RequestPerson.RequestPersonStatusID)
            {
                case RequestPersonStatus.WaitForArrive:
                    this.Status = "در انتظار آمدن";
                    break;
                case RequestPersonStatus.Arrive:
                    this.Status = "ورود به هتل";
                    break;
                case RequestPersonStatus.Leave:
                    this.Status = "خروج از هتل";
                    break;
            }
            this.Timestamp = RequestPerson.Timestamp.ToHijriSolarString();
            this.BackColor = RequestPerson.IsDeleted ? "#FF5555" : "#FFFFFF";
        }

        public static List<RequestPerson> Convert(List<DataAccessLayer.RequestPerson> RequestPersons)
        {
            return (RequestPersons.ConvertAll(new Converter<DataAccessLayer.RequestPerson, RequestPerson>(p => (new RequestPerson(p)))));
        }
    }
}
